package com.ilibrary.web.action;

import com.ilibrary.base.MyBaseAction;
import com.ilibrary.service.NewsCategoryService;
import com.ilibrary.service.NewsService;
import com.ilibrary.web.dto.ResultDto;
import com.ilibrary.web.vo.NewsVO;

public class NewsViewAction extends MyBaseAction {
	private NewsService newsService;
	private NewsCategoryService newsCategoryService;
	
	public NewsService getNewsService() {
		return newsService;
	}
	public void setNewsService(NewsService newsService) {
		this.newsService = newsService;
	}
	public NewsCategoryService getNewsCategoryService() {
		return newsCategoryService;
	}
	public void setNewsCategoryService(NewsCategoryService newsCategoryService) {
		this.newsCategoryService = newsCategoryService;
	}
	
	@Override
	public String execute() throws Exception {
		int newsId = Integer.parseInt(getRQ().getParameter("newsId"));
		ResultDto<NewsVO> resultDto = newsService.findById(newsId);
		NewsVO newsVO = resultDto.getFirstResult();
		getRQ().setAttribute("newsVO", newsVO);
		return SUCCESS;
	}
	
}
